<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>前端Hardy</title>
    <style>
        body {
            margin: 0;
            padding: 0;
            background: #000;
            overflow: hidden;
            height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        #controls {
            position: fixed;
            top: 10px;
            left: 10px;
            z-index: 100;
            display: flex;
            align-items: center;
        }

        .btn {
            background-color: rgba(0, 0, 0, 0.4);
            border: none;
            color: rgba(255, 255, 255, 0.4);
            padding: 10px;
            text-align: center;
            text-decoration: none;
            display: inline-block;
            font-size: 16px;
            margin: 2px 2px;
            cursor: pointer;
            border-radius: 5px;
            transition: background-color 0.3s;
        }

        .btn:hover {
            background-color: rgba(255, 255, 255, 0.2);
            color: rgba(255, 255, 0, 1);
        }

        #fullscreenBtn {
            font-size: 20px;
        }

        .textwall-night {
            width: 100vw;
            height: 100vh;
            position: relative;
            overflow: hidden;
        }

        .text-piece {
            position: absolute;
            font-size: 12px;
            line-height: 1;
            color: transparent;
            text-shadow: none;
            animation: twinkle 1.5s infinite alternate, moveOutward 10s linear infinite,
                colorChange 4s infinite;
            font-family: monospace;
            white-space: nowrap;
        }

        @keyframes twinkle {
            0% {
                opacity: 0.7;
            }

            100% {
                opacity: 1;
            }
        }

        @keyframes moveOutward {
            0% {
                transform: translate(0, 0) rotate(0deg);
            }

            100% {
                transform: translate(var(--tx), var(--ty)) rotate(360deg);
            }
        }

        @keyframes colorChange {
            0% {
                color: #4a437f;
                text-shadow: 0 0 5px #4a437f;
            }

            20% {
                color: #6f75aa;
                text-shadow: 0 0 5px #6f75aa;
            }

            40% {
                color: #fff5bd;
                text-shadow: 0 0 5px #fff5bd;
            }

            60% {
                color: #ffd966;
                text-shadow: 0 0 5px #ffd966;
            }

            80% {
                color: #466b91;
                text-shadow: 0 0 5px #466b91;
            }

            100% {
                color: #4a437f;
                text-shadow: 0 0 5px #4a437f;
            }
        }
    </style>
</head>

<body>
    <div id="controls">
        <button id="fullscreenBtn" class="btn" title="Toggle Fullscreen">⤢</button>
    </div>
    <div class="textwall-night"></div>
    <script>
        let loremText = "";
        for (let i = 0; i < 51; i++) {
            loremText += "喜欢你";
            if (i < 49) {
                loremText += "，";
            }
        }
        console.log(loremText);
        const quantity = 150;

        const colors = [
            "#4a437f",
            "#6f75aa",
            "#fff5bd",
            "#ffd966",
            "#c7b683",
            "#466b91",
            "#2d4263"
        ];

        const textwall = document.querySelector(".textwall-night");
        let width = window.innerWidth;
        let height = window.innerHeight;

        for (let i = 0; i < quantity; i++) {
            const piece = document.createElement("div");
            piece.className = "text-piece";

            const t = i * 0.1;
            let x = width / 2 + ((Math.cos(t) * (t * 2)) % width);
            let y = height / 2 + ((Math.sin(t) * (t * 2)) % height);

            const angle = Math.random() * Math.PI * 2;
            const distance = Math.random() * 500 + 500;
            const tx = Math.cos(angle) * distance;
            const ty = Math.sin(angle) * distance;

            piece.style.setProperty("--tx", `${tx}px`);
            piece.style.setProperty("--ty", `${ty}px`);
            piece.style.left = `${x}px`;
            piece.style.top = `${y}px`;
            piece.style.animationDelay = `${Math.random() * 2.5}s`;
            piece.style.fontSize = `${Math.random() * 8 + 12}px`;

            const startPos = Math.floor(Math.random() * (loremText.length - 20));
            piece.textContent = loremText.substr(startPos, 20);

            textwall.appendChild(piece);
        }

        document.querySelectorAll(".text-piece").forEach((piece) => {
            piece.addEventListener("mouseover", () => {
                piece.style.transform = `scale(1.5)`;
                piece.style.zIndex = "1000";
                piece.style.transition = "transform 0.3s ease";
            });

            piece.addEventListener("mouseout", () => {
                piece.style.transform = "";
                piece.style.zIndex = "";
            });
        });

        const fullscreenBtn = document.getElementById("fullscreenBtn");
        fullscreenBtn.addEventListener("click", toggleFullScreen);

        function toggleFullScreen() {
            if (!document.fullscreenElement) {
                document.documentElement.requestFullscreen();
            } else {
                if (document.exitFullscreen) {
                    document.exitFullscreen();
                }
            }
        }
    </script>
</body>

</html>